package com.ruoyi.imRank.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.imRank.domain.IfmRank;
import com.ruoyi.imRank.service.IIfmRankService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 职级Controller
 * 
 * @author ruoyi
 * @date 2024-11-01
 */
@RestController
@RequestMapping("/imRank/imRankm")
public class IfmRankController extends BaseController
{
    @Autowired
    private IIfmRankService ifmRankService;

    /**
     * 查询职级列表
     */
    @PreAuthorize("@ss.hasPermi('imRank:imRankm:list')")
    @GetMapping("/list")
    public TableDataInfo list(IfmRank ifmRank)
    {
        startPage();
        List<IfmRank> list = ifmRankService.selectIfmRankList(ifmRank);
        return getDataTable(list);
    }

    /**
     * 导出职级列表
     */
    @PreAuthorize("@ss.hasPermi('imRank:imRankm:export')")
    @Log(title = "职级", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, IfmRank ifmRank)
    {
        List<IfmRank> list = ifmRankService.selectIfmRankList(ifmRank);
        ExcelUtil<IfmRank> util = new ExcelUtil<IfmRank>(IfmRank.class);
        util.exportExcel(response, list, "职级数据");
    }

    /**
     * 获取职级详细信息
     */
    @PreAuthorize("@ss.hasPermi('imRank:imRankm:query')")
    @GetMapping(value = "/{rankId}")
    public AjaxResult getInfo(@PathVariable("rankId") Long rankId)
    {
        return success(ifmRankService.selectIfmRankByRankId(rankId));
    }

    /**
     * 新增职级
     */
    @PreAuthorize("@ss.hasPermi('imRank:imRankm:add')")
    @Log(title = "职级", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody IfmRank ifmRank)
    {
        return toAjax(ifmRankService.insertIfmRank(ifmRank));
    }

    /**
     * 修改职级
     */
    @PreAuthorize("@ss.hasPermi('imRank:imRankm:edit')")
    @Log(title = "职级", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody IfmRank ifmRank)
    {
        return toAjax(ifmRankService.updateIfmRank(ifmRank));
    }

    /**
     * 删除职级
     */
    @PreAuthorize("@ss.hasPermi('imRank:imRankm:remove')")
    @Log(title = "职级", businessType = BusinessType.DELETE)
	@DeleteMapping("/{rankIds}")
    public AjaxResult remove(@PathVariable Long[] rankIds)
    {
        return toAjax(ifmRankService.deleteIfmRankByRankIds(rankIds));
    }
}
